<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$setting=$this->setting;
set_html('title','绑员工二维码');
if($_RQ['op']=='main'){
	if(!$_RQ['adminmid']){
		exi('请扫绑员工二维码！','error');
	}
	if(!$_SESSION['uid']){
		$return['ischecklogin']=model('jy_weishop/member')->checklogin('','','','',true);
	}else{
		$worker=pdo_get('jy_yuejie_worker',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
		if($worker['id']){
			exi('已经是公司员工了！','','jy_yuejie/index/');
		}
		$data=array(
			'status'=>1,
			'cfee'=>800,
		);
		$check=pdo_get('jy_weishop_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'merchid'=>0));
		if(!$check['id']){
			exi('该会员不存在！无法添加员工！','error');
		}
		$data['uniacid']=$_SESSION['uniacid'];
		$data['mid']=$_SESSION['uid'];
		$data['adminmid']=$_RQ['adminmid'];
		$data['createtime']=time();
		pdo_insert('jy_yuejie_worker',$data);
		pdo_update('jy_weishop_member',array('yuejie_type'=>2),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'merchid'=>0));
	}
	$setting['saotourl']='jy_yuejie/index/';
	exi('扫绑员工成功！','',$setting['saotourl']);
}

?>